<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>URL 片段编码工具</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            max-width: 800px;
            margin: 0 auto;
            padding: 20px;
            background-color: #f5f5f5;
        }
        .container {
            background-color: white;
            padding: 30px;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        }
        h1 {
            color: #333;
            text-align: center;
            margin-bottom: 30px;
        }
        .input-group {
            margin-bottom: 20px;
        }
        label {
            display: block;
            margin-bottom: 5px;
            font-weight: bold;
            color: #555;
        }
        input[type="text"] {
            width: 100%;
            padding: 12px;
            border: 1px solid #ddd;
            border-radius: 4px;
            box-sizing: border-box;
            font-size: 16px;
        }
        button {
            background-color: #4CAF50;
            color: white;
            padding: 12px 24px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 16px;
            width: 100%;
            margin-top: 10px;
        }
        button:hover {
            background-color: #45a049;
        }
        .result {
            margin-top: 30px;
            padding: 15px;
            background-color: #e9f7ef;
            border-radius: 4px;
            border-left: 4px solid #4CAF50;
        }
        .result-label {
            font-weight: bold;
            color: #333;
            margin-bottom: 10px;
        }
        #output {
            word-break: break-all;
            font-family: monospace;
            font-size: medium;
            background-color: #f8f8f8;
            padding: 10px;
            border-radius: 4px;
            border: 1px solid #ddd;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>URL 片段编码工具</h1>
        
        <div class="input-group">
            <label for="type">type 参数:</label>
            <input type="text" id="type" placeholder="请输入type参数" value="2">
        </div>
        
        <div class="input-group">
            <label for="code">code 参数:</label>
            <input type="text" id="code" placeholder="请输入code参数" value="gh_0234092de4fa">
        </div>
        
        <div class="input-group">
            <label for="path">path 参数:</label>
            <input type="text" id="path" placeholder="请输入path参数" value="/pages/shopHomepage/shopHomepage?id=122&appid=b94fcbdd02fc42de9168cc778fec53ba">
        </div>
        
        <button onclick="encodeAndConcat()">编码并拼接</button>
        
        <div class="result">
            <div class="result-label">结果:</div>
            <div id="output">编码后的 URL 将显示在这里</div>
        </div>
    </div>

    <script>
        function encodeAndConcat() {
            // 获取输入值
            const type = document.getElementById('type').value;
            const code = document.getElementById('code').value;
            const path = document.getElementById('path').value;
            
            // 检查输入是否为空
            if (!type || !code || !path) {
                alert('请填写所有参数');
                return;
            }
            
            // 对 path 进行 URL 编码
            const encodedPath = encodeURIComponent(path);
            
            // 拼接结果
            const result = `openMini://?type=${type}&code=${code}&path=${encodedPath}`;
            
            // 显示结果
            document.getElementById('output').textContent = result;
        }
    </script>
</body>
</html>
